<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.w3.org/1999/xhtml"
      layout:decorator="inc/layout"
>
<head>
    <meta charset="UTF-8"/>
    <title>全部评论</title>
    <script>



        function deleteCourseReview(id) {
            layer.confirm('确定要删除该评论吗？', {
                btn: ['确定', '取消']
            }, function () {
                $.post(ctxPath + "courseReview/delete", {id: id}, function (data) {
                    layer.alert(data, function () {
                        location.reload();
                    });

                })

            });
        }



    </script>

</head>
<body>


<div class="container" layout:fragment="content">

    <table th:if="${courseReviews.size()>0}" class="table table-bordered  table-hover" style="margin-top: 50px">
        <thead>
        <tr class="success">
            <td th:width="60">课程ID</td>
            <td>描述</td>
            <td th:width="60">用户ID</td>
            <td th:width="120">用户</td>
            <td th:width="120">用户昵称</td>
            <td th:width="200">课程</td>
            <td th:width="80">编辑</td>

        </tr>
        </thead>
        <tbody>

        <tr th:each="p:${courseReviews}">
            <td th:text="${p.course.id}"></td>
            <td th:text="${p.description}"></td>
            <td th:text="${p.user.id}"></td>
            <td th:text="${p.user.name}"></td>
            <td th:text="${p.user.nickname}"></td>
            <td th:text="${p.course.name}"></td>
            <td>
                <span style="cursor: pointer">
                    <span class="btn-primary btn-sm" th:onclick="'deleteCourseReview(' + ${p.id} + ')'">删除</span>
                </span>
            </td>
        </tr>
        </tbody>

    </table>
    <h1 th:if="${courseReviews.size()==0}" class="text-center">当前没有评论</h1>


</div>

</body>
</html>